// *****************************************************
// Aitrox Information Technology
// http://www.proxima-ai.com
// Copyright 2021 Aitrox. All rights reserved.
//
// Filename: diskstatus.go
// CreateDate: 2023-06-08
// Author: zjp
// Description: 磁盘使用情况请求
// ******************************************************
package v1

import (
	"usplatformserver/internal/service"
	"usplatformserver/pkg/app"
	"usplatformserver/pkg/errcode"

	"github.com/gin-gonic/gin"
)

// @Summer 获取磁盘状态
// @Produce json
// @Param token header string true "token"
// @Success 200 {object} model.DiskStatusSwagger "成功"
// @Failure 400 {object} errcode.Error "请求错误"
// @Failure 500 {object} errcode.Error "内部错误"
// @Router /api/v1/diskusage [get]
func GetDiskUsage(c *gin.Context) {

	response := app.NewResponse(c)

	svc := service.New(c.Request.Context())
	filePath := "/"

	disk, err := svc.DiskUsage(filePath)
	if err != nil {
		response.ToErrorResponse(errcode.ErrorGetDiskUsageFail)
		return
	}
	response.ToResponse(disk)
}
